From d3d206daadfebadf4edb7a5a9a2fdab8ec960344 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 1 Mar 2016 08:25:22 -0800 Subject: [PATCH] Add a regression test for the issue being fixed When compiling a package from two separate locations it should be cached the same way both times. --- src/cargo/ops/cargo_read_manifest.rs | 1 - tests/test_cargo_bench.rs | 6 +-- tests/test_cargo_compile_path_deps.rs | 2 +- tests/test_cargo_freshness.rs | 64 +++++++++++++++++++++++++++ tests/test_cargo_install.rs | 2 +- 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 20a672e28..ddaace342 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -1,6 +1,5 @@ use std::collections::{HashMap, HashSet}; use std::fs; -use std::io::prelude::*; use std::io; use std::path::{Path, PathBuf}; diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index 0e16211c5..c98035d5c 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -299,7 +299,7 @@ test!(bench_with_deep_lib_dep { assert_that(p.cargo_process("bench"), execs().with_status(0) .with_stdout(&format!("\ -{compiling} foo v0.0.1 ({dir}) +{compiling} foo v0.0.1 ([..]) {compiling} bar v0.0.1 ({dir}) {running} target[..] @@ -705,7 +705,7 @@ test!(bench_dylib { assert_that(p.cargo_process("bench").arg("-v"), execs().with_status(0) .with_stdout(&format!("\ -{compiling} bar v0.0.1 ({dir}) +{compiling} bar v0.0.1 ({dir}/bar) {running} [..] -C opt-level=3 [..] {compiling} foo v0.0.1 ({dir}) {running} [..] -C opt-level=3 [..] @@ -732,7 +732,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured assert_that(p.cargo("bench").arg("-v"), execs().with_status(0) .with_stdout(&format!("\ -{fresh} bar v0.0.1 ({dir}) +{fresh} bar v0.0.1 ({dir}/bar) {fresh} foo v0.0.1 ({dir}) {running} [..]target[..]release[..]bench-[..] diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 9eaaac0a8..5cd97d301 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -517,7 +517,7 @@ Caused by: failed to read `[..]bar[..]Cargo.toml` Caused by: - No such file or directory ([..]) + [..] (os error [..]) ")); }); diff --git a/tests/test_cargo_freshness.rs b/tests/test_cargo_freshness.rs index 152190cf0..dc1a402df 100644 --- a/tests/test_cargo_freshness.rs +++ b/tests/test_cargo_freshness.rs @@ -288,3 +288,67 @@ test!(rerun_if_changed_in_dep { assert_that(p.cargo("build"), execs().with_status(0).with_stdout("")); }); + +test!(same_build_dir_cached_packages { + let p = project("foo") + .file("a1/Cargo.toml", r#" + [package] + name = "a1" + version = "0.0.1" + authors = [] + [dependencies] + b = { path = "../b" } + "#) + .file("a1/src/lib.rs", "") + .file("a2/Cargo.toml", r#" + [package] + name = "a2" + version = "0.0.1" + authors = [] + [dependencies] + b = { path = "../b" } + "#) + .file("a2/src/lib.rs", "") + .file("b/Cargo.toml", r#" + [package] + name = "b" + version = "0.0.1" + authors = [] + [dependencies] + c = { path = "../c" } + "#) + .file("b/src/lib.rs", "") + .file("c/Cargo.toml", r#" + [package] + name = "c" + version = "0.0.1" + authors = [] + [dependencies] + d = { path = "../d" } + "#) + .file("c/src/lib.rs", "") + .file("d/Cargo.toml", r#" + [package] + name = "d" + version = "0.0.1" + authors = [] + "#) + .file("d/src/lib.rs", "") + .file(".cargo/config", r#" + [build] + target-dir = "./target" + "#); + p.build(); + + assert_that(p.cargo("build").cwd(p.root().join("a1")), + execs().with_status(0).with_stdout(&format!("\ +{compiling} d v0.0.1 ({dir}/d) +{compiling} c v0.0.1 ({dir}/c) +{compiling} b v0.0.1 ({dir}/b) +{compiling} a1 v0.0.1 ({dir}/a1) +", compiling = COMPILING, dir = p.url()))); + assert_that(p.cargo("build").cwd(p.root().join("a2")), + execs().with_status(0).with_stdout(&format!("\ +{compiling} a2 v0.0.1 ({dir}/a2) +", compiling = COMPILING, dir = p.url()))); +}); diff --git a/tests/test_cargo_install.rs b/tests/test_cargo_install.rs index 247b654dd..f385086ca 100644 --- a/tests/test_cargo_install.rs +++ b/tests/test_cargo_install.rs @@ -127,7 +127,7 @@ Caused by: failed to read `[..]Cargo.toml` Caused by: - No such file or directory ([..]) + [..] (os error [..]) ")); }); -- 2.30.2